﻿using DAL;
using Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MainOP
{
    public class PermissionCheck
    {
        /// <summary>
        /// 权限验证
        /// </summary>
        /// <param name="userlogin"></param>
        /// <returns></returns>
        public static int PernChk(UserLogin userlogin)
        {
            userlogin = UserManagement.GetUser(userlogin.Admin, userlogin.Pwd);
            if (userlogin.Admin == null)
            {
                FormUserLoginInterface frmuserLogin = new FormUserLoginInterface();
                frmuserLogin.Text = "用户登陆";
                frmuserLogin.Icon = new Icon(@"UserLogin.ico");
                DialogResult Result = frmuserLogin.ShowDialog();
                if (Result == DialogResult.OK)
                {
                    return userlogin.UserID;
                }
                else
                {
                    return 4;
                }
            }
            else
            {
                return 4;
            }
        }


    }
}
